package com.example.neusoft.yuejian_tea;

import android.content.Intent;
import android.graphics.Color;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.ImageView;

import com.jude.rollviewpager.RollPagerView;
import com.jude.rollviewpager.adapter.StaticPagerAdapter;
import com.jude.rollviewpager.hintview.ColorPointHintView;

public class MainActivity extends AppCompatActivity {
    private RollPagerView mRollViewPager;
    private Button btnimage;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        initRollPagerView();
        findViewById(R.id.button).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent=new Intent(MainActivity.this,ImageActivity.class);
                startActivity(intent);
            }
        });
    }

    private void initRollPagerView() {

        mRollViewPager=findViewById(R.id.rollpagerview);
        //设置播放时间间隔
        mRollViewPager.setPlayDelay(1000);
         //设置透明度
         mRollViewPager.setAnimationDurtion(500);
         //设置适配器
         mRollViewPager.setAdapter(new TestNormalAdapter());
         //设置指示器（顺序依次）
         //自定义指示器图片
         //设置圆点指示器颜色
         //设置文字指示器
         //隐藏指示器
         //mRollViewPager.setHintView(new IconHintView(this, R.drawable.point_focus, R.drawable.point_normal));
         mRollViewPager.setHintView(new ColorPointHintView(this, Color.YELLOW,Color.WHITE));
         //mRollViewPager.setHintView(new  TextHintView(this));
         //mRollViewPager.setHintView(null);

    }

    private  class  TestNormalAdapter  extends  StaticPagerAdapter  {
          private  int[]  imgs  =  {
                    R.drawable.lunbotu1,
                    R.drawable.lunbotu2,
                    R.drawable.lunbotu3,
                    R.drawable.lunbotu4,
          };

          @Override
          public View getView(ViewGroup container, int  position)  {
                    ImageView view  =  new  ImageView(container.getContext());
                    view.setImageResource(imgs[position]);
                    view.setScaleType(ImageView.ScaleType.CENTER_CROP);
                    view.setLayoutParams(new  ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,  ViewGroup.LayoutParams.MATCH_PARENT));
                    return  view;
          }

          @Override
          public  int  getCount()  {
                  return  imgs.length;
          }
    }

}
